#ifndef _geo_point_h_
#define _geo_point_h_

#include <iostream>
#include <math.h>
#include <geo/vector.h>

namespace contest
{

/**
 * 2D point class
 * @template T: Type of coordinates (i.e. int, int64_t, float, double, fraction)
 **/
template <class T> class point
{
public:
    T x;
    T y;
    point(): x(0), y(0)
    {
    }
    point(T x0, T y0): x(x0), y(y0)
    {
    }
    point(const point<T>& p): x(p.x), y(p.y)
    {
    }
    vector<T> operator-(const point<T>& rhs) const
    {
        return vector<T>(x - rhs.x, y - rhs.y);
    }
    bool operator ==(const point<T>& rhs) const
    {
        return x == rhs.x && y == rhs.y;
    }
    friend std::ostream& operator<<(std::ostream& out, const point<T>& s)
    {
        std::cout<<"("<<s.x<<","<<s.y<<")";
    }
};

/**
 * xyorder. Use it to sort points.
 **/
template <class T> struct xyorder
{
    bool operator()(const point<T>& lhs, const point<T>& rhs)
    {
        if (lhs.x == rhs.x)
            return lhs.y < rhs.y;
        return lhs.x < rhs.x;
    }
};

/**
 * xyorder. Use it to sort points.
 **/
template <class T> struct yxorder
{
    bool operator()(const point<T>& lhs, const point<T>& rhs)
    {
        if (lhs.y == rhs.y)
            return lhs.x < rhs.x;
        return lhs.y < rhs.y;
    }
};

}

#endif
